package main

import (
	"fmt"
	"strconv"
	"time"
)

func printMsg2() {
	for i := 0; i < 15; i++ {
		fmt.Println("hello world" + strconv.Itoa(i))
		time.Sleep(time.Second)
	}
}

func main() {
	//go printMsg2() // 开启协程

	//for i := 0; i < 5; i++ {
	//	fmt.Println("hello main" + strconv.Itoa(i))
	//	time.Sleep(time.Second)
	//}

	// 匿名函数，闭包， 开启多线程
	for i := 0; i < 5; i++ {
		go func(num int) {
			fmt.Println(num)
		}(i)
	}
	time.Sleep(time.Second * 2)
}
